<template>
<div>


    <van-cell-group>
        <van-field 
            v-model="content" 
            :label="label" 
            :placeholder="placeholder" 
            :rule="rule"
            :type="type"
            autocomplete="off"
        />
    </van-cell-group>



</div>
</template>

<script>

export default {
    data() {
        return {
            content:""
        };
    },
     methods: {
        handlerulg(){
            let rue = new RegExp(this.rule)//将正则表达式（字符串类型的）转换为正式的正则
            if(rue.test(this.content)){//监听这个content的值
                // alert("正则校验ok")
                this.$emit("inputChange",this.content)
            }
        }

    },

    watch:{
        content(){
            this.handlerulg()
        }

    },

    props:[ 'label','placeholder',"type","rule" ]




    }
</script>


<style scoped>

</style>